package com.chensheng.dao;

import com.chensheng.model.OrderDetail;
import org.apache.ibatis.annotations.*;

import java.util.List;


/**
 * @Author:ChenSheng
 * @Description:
 * @Date: Created in 下午 19:58 2018/5/13 0013
 */
@Mapper
public interface OrderDetailDAO {

    @Select({"select * from order_detail where detail_id= #{detailId}"})
    OrderDetail selectOrderdetail(@Param("detailId") int detailId);

    @Select({"select * from order_detail where detail_id= #{detailId}"})
    OrderDetail selectByEntity(OrderDetail orderDetail);

    @Insert({"insert into order_detail (detail_id, order_id, product_id, product_name, product_price, product_quantity, product_icon) " +
            "values (#{detailId}, #{orderId}, #{productId}, #{productName}, #{productPrice}, #{productQuantity}, #{productIcon})"})
    void insert(OrderDetail orderDetail);

    @Update({"update order_detail set product_id=#{productId} where detail_id=#{detailId}"})
    void update(@Param("productId") String productId, @Param("detailId") String detailId);


    @Insert({"insert order_detail values " +
            "(#{detailId}, #{orderId}, #{productId}, #{productName}, #{productPrice}, #{productQuantity}, #{productIcon}, #{createTime}, #{updateTime})"})
    void insertOne(OrderDetail orderDetail);

    @Select({"select * from order_detail where order_id = #{orderId}"})
    List<OrderDetail> selectByOrderId(@Param("orderId") String orderId);
}
